package com.tencent.qcloud.tim.demo.main;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.just.agentweb.AgentWeb;
import com.tencent.qcloud.tim.demo.R;
import com.tencent.qcloud.tim.uikit.base.BaseFragment;
import com.tencent.qcloud.tim.uikit.component.TitleBarLayout;

public class ShopFragment extends BaseFragment {

    private AgentWeb mAgentWeb;
    private TitleBarLayout mTitleBar;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View baseView = inflater.inflate(R.layout.frag_shop, container, false);
        initWeb(baseView);
        return baseView;
    }

    private void initWeb(View v){
        mTitleBar = v.findViewById(R.id.shop_titlebar);
        mTitleBar.setTitle(getResources().getString(R.string.tab_shop_tab_text), TitleBarLayout.POSITION.MIDDLE);
        mTitleBar.getLeftGroup().setVisibility(View.GONE);
        mTitleBar.getRightIcon().setVisibility(View.GONE);
        mAgentWeb = AgentWeb.with(getActivity())
                .setAgentWebParent((LinearLayout) v, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator()
                .createAgentWeb()
                .ready()
                .go("http://www.jd.com");
    }

    @Override
    public void onPause() {
        mAgentWeb.getWebLifeCycle().onPause();
        super.onPause();

    }

    @Override
    public void onResume() {
        mAgentWeb.getWebLifeCycle().onResume();
        super.onResume();
    }
    @Override
    public void onDestroyView() {
        mAgentWeb.getWebLifeCycle().onDestroy();
        super.onDestroyView();
    }
}
